<?php
	$pagename = split("/" , $_SERVER['QUERY_STRING']);
	$pn_length = count($pagename);
	//echo "length=".$pn_length;
	//echo $pagename[$pn_length-1];
	$file = $pagename[$pn_length-1];
	
?>
<nav>  
    <ul class="menu">
    	<?php
        	if($param == $file){$cur1 = " class = 'current' ";}else{$cur1 = "";}
		?>
    	<li <?php echo $cur1?>>
            <a href="index.php">
				<?php
                    if($lang == '2'){echo "หน้าหลัก";}else{echo "home";}
                ?>
            </a>
        </li>
    	<?php
        	$topmenu = Q2("select * from module order by md_order DESC"); 
			foreach($topmenu as $tp){
				$param = "opor={$tp['md_id']}";
				if($param == $file){$cur4 = " class = 'current' ";}else{$cur4 = "";}
				if($lang == '2'){
					
					if(strstr($tp['md_function'] , "บทความ")){
					?>
                   	 <li <?php echo $cur4?>><a href="topic.php?opor=<?php echo $tp['md_id']?>"><?php echo $tp['md_name2']?></a></li>
                    <?php	
					}else if(strstr($tp['md_function'] , "แผนที่")){
					?>
                   	 <li <?php echo $cur4?>><a href="map.php?opor=<?php echo $tp['md_id']?>"><?php echo $tp['md_name2']?></a></li>
                    <?php	
					}else if(strstr($tp['md_function'] , "แบบฟอร์มติดต่อเรา")){
					?>
                   	 <li <?php echo $cur4?>><a href="contact.php?opor=<?php echo $tp['md_id']?>"><?php echo $tp['md_name2']?></a></li>
                    <?php	
					}else if(strstr($tp['md_function'] , "อัลบั้มภาพ")){
					?>
                   	 <li <?php echo $cur4?>><a href="gallery.php?opor=<?php echo $tp['md_id']?>"><?php echo $tp['md_name2']?></a></li>
                    <?php	
					}
				}else if($lang == '1'){
					if(strstr($tp['md_function'] , "บทความ")){
					?>
                   	 <li <?php echo $cur4?>><a href="topic.php?opor=<?php echo $tp['md_id']?>"><?php echo $tp['md_name']?></a></li>
                    <?php	
					}else if(strstr($tp['md_function'] , "แผนที่")){
					?>
                   	 <li <?php echo $cur4?>><a href="map.php?opor=<?php echo $tp['md_id']?>"><?php echo $tp['md_name']?></a></li>
                    <?php	
					}else if(strstr($tp['md_function'] , "แบบฟอร์มติดต่อเรา")){
					?>
                   	 <li <?php echo $cur4?>><a href="contact.php?opor=<?php echo $tp['md_id']?>"><?php echo $tp['md_name']?></a></li>
                    <?php	
					}else if(strstr($tp['md_function'] , "อัลบั้มภาพ")){
					?>
                   	 <li <?php echo $cur4?>><a href="gallery.php?opor=<?php echo $tp['md_id']?>"><?php echo $tp['md_name']?></a></li>
                    <?php	
					}
				}
				
			}
		?>
        
        
       
    </ul>
    <div class="clear"></div>
 </nav>